package com.dayilyword.config.resultFormat;

import lombok.Getter;
import lombok.Setter;

public enum ResultEnum {

    /**
     * 系统接口
     */
    SUCCESS(0, "SUCCESS"),
    ERROR(-1, "ERROR"),

    /**
     * 用户登录状态
     */

//    LOGIN_FAIL(101, "登录失败"),
    LOGIN_FAIL(101, "user.LOGIN_FAIL"),
    LOGIN_TIME_OUT(102, "user.LOGIN_TIME_OUT"),
    LOGIN_AUTH_FAIL(103, "user.LOGIN_AUTH_FAIL"),
    NOT_LOGIN(104, "user.NOT_LOGIN"),
    REGISTERED(105, "user.REGISTERED");


    @Getter
    @Setter
    private Integer code;
    @Getter
    @Setter
    private String msg;

    ResultEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public  String getName(int index) {
        for (ResultEnum c : ResultEnum.values()) {
            if (c.getCode() == index) {
                return c.msg;
            }
        }
        return null;
    }
}
